package com.etc.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.etc.entity.Blog;
import com.etc.service.BlogService;

@Controller
public class BlogController {

	@Resource
	private BlogService bs;
	
	
	@RequestMapping(value="/list/{blogId}",method = RequestMethod.GET)
	@ResponseBody
	public Blog listBlog1(@PathVariable(value="blogId") int blogId)
	{

	return	 bs.getBlogById(blogId);
	
	}
	
	@RequestMapping(value="/list",method = RequestMethod.GET)
	public String listBlog2(Model model)
	{
		
		Blog blog = bs.getBlogById(4);
		model.addAttribute("blog", blog);
		return "list";
	}
	
	
	
	

}
